package com.hua.api.modules.order.rest;

import com.hua.api.core.constants.Status;
import com.hua.api.core.framework.annotation.TokenCheck;
import com.hua.api.core.framework.util.Result;
import com.hua.api.modules.order.service.OrderInfoService;
import com.hua.api.modules.order.service.dto.OrderInfoCriteria;
import com.hua.api.modules.order.service.dto.SelfOrderDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import com.hua.api.core.framework.annotation.AnonymousAccess;
import com.hua.api.modules.order.service.dto.OrderInfoDto;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/orderInfo")
public class OrderInfoController {

    private final OrderInfoService orderInfoService;

    @AnonymousAccess
    @PostMapping("/create")
    // @TokenCheck(userAgent = "OrderInfoCreate")
    public Result orderCreate(@RequestBody SelfOrderDto data){
        orderInfoService.orderInfoCreate(data);
        return Result.success();
    }


    // 管理后台取消订单
    // @AnonymousAccess
    @RequestMapping("/cancel/{orderNo}")
    @TokenCheck(userAgent = "cancelOrderInfo",roleId = { Status.admin })
    public Result cancel(@PathVariable String orderNo, @RequestBody OrderInfoCriteria dto){
        orderInfoService.cancelOrderInfo(orderNo, dto);
        return Result.success();
    }


    


}
